package com.credithc.customers.base.mapper;

import com.credithc.baseserv.core.mapper.BsBaseMapper;
import com.credithc.customers.base.po.PreCustomerInfoPo;
import com.credithc.customers.base.vo.PreCustomerDetailVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhukai
 * @date 2018/11/28 14:46
 */
@Mapper
@Repository
public interface PreCustomerMapper extends BsBaseMapper<PreCustomerInfoPo> {

    @Select("SELECT b.id id, b.pre_customer_no preCustomerNo,a.id extendId,a.customer_no customerNo,a.sub_system_sign subSystemSign, b.contact_type contactType, b.contact_info contactInfo,\n" +
            " a.status status FROM cust_pre_info b JOIN  cust_extend a ON a.pre_customer_no = b.pre_customer_no WHERE b.contact_info = #{phone} AND b.contact_type = '1' AND a.sub_system_sign=#{subSystemSign} AND a.status != 6")
    List<PreCustomerDetailVo> getPreInfo(@Param("phone") String phone, @Param("subSystemSign") String subSystemSign);

    @Select("SELECT b.id id, b.pre_customer_no preCustomerNo,a.id extendId,a.customer_no customerNo,a.sub_system_sign subSystemSign, b.contact_type contactType, b.contact_info contactInfo,\n" +
            " a.status status FROM cust_pre_info b JOIN  cust_extend a ON a.pre_customer_no = b.pre_customer_no WHERE b.contact_info = #{phone} AND b.contact_type = '1' AND a.status != 6")
    List<PreCustomerDetailVo> getPreInfoOnly(@Param("phone") String phone);
}
